class TFCNGun extends TFWeapon;

var xEmitter  chargeEmitterB, chargingEmitterB;
var bool bshotout;   // only destroys weapon if this is false

simulated function Tick(float dt)
{
    if(!HasAmmo() && !bshotout)
	{
	    tfpri(pawn(owner).playerreplicationinfo).usedcredits -=2000;
        DetachFromPawn(instigator);
        Instigator.DeleteInventory(self);
        instigator.controller.SwitchToBestWeapon();
        Destroy();
    }
}

function Detonate()
{
    local tfcnaltproj proj, candidate;

    foreach DynamicActors(class'Taskforces.TFCNAltProj',proj)
    {
        if(proj.instigator!=none && proj.instigator==instigator && (candidate==none || proj.lifespan<candidate.lifespan))
            candidate=proj;
    }

    if(candidate!=none) candidate.Detonate();
}

simulated function BringUp(optional Weapon PrevWeapon)
{
    if ( PlayerController(Instigator.Controller) != None )
    {
		if ( Instigator.IsLocallyControlled() )
			GotoState('TickEffects');
	}
    Super.BringUp(PrevWeapon);
}

simulated function OutOfAmmo()
{
    if ( !Instigator.IsLocallyControlled() || HasAmmo() )
        return;

    if(tfpri(pawn(owner).playerreplicationinfo)!=none)
        tfpri(pawn(owner).playerreplicationinfo).hassuperweapon=false;

    //DoAutoSwitch();
}

defaultproperties
{
     FireModeClass(0)=Class'taskforces.TFCNFire'
     FireModeClass(1)=Class'taskforces.TFCNAltFire'
     PutDownAnim="PutDown"
     SelectSound=Sound'TFMedia.Cannoneer.CNslct'
     SelectForce="ballgun_change"
     AIRating=0.100000
     CurrentRating=0.100000
     bDoAmmoRegen=False
     EffectOffset=(X=100.000000,Y=20.000000,Z=-7.000000)
     DisplayFOV=60.000000
     HudColor=(B=160,G=115,R=100)
     SmallViewOffset=(X=23.000000,Y=6.000000,Z=-6.000000)
     CenteredOffsetY=-12.000000
     CenteredRoll=3000
     CenteredYaw=-300
     InventoryGroup=0
     GroupOffset=4
     PickupClass=Class'taskforces.TFCNPickup'
     PlayerViewOffset=(X=-45.000000,Y=-10.000000,Z=5.000000)
     BobDamping=2.500000
     AttachmentClass=Class'taskforces.TFCNGunAttach'
     IconMaterial=Texture'HUDContent.Generic.HUD'
     IconCoords=(X1=169,Y1=78,X2=244,Y2=124)
     ItemName="SiegeCannon"
     Mesh=SkeletalMesh'Weapons.LinkGun_1st'
     DrawScale=0.800000
     DrawScale3D=(X=2.200000,Y=2.000000,Z=1.200000)
     Skins(0)=Texture'TFMedia.Cannoneer.tfCNGunTex0'
     UV2Texture=Shader'XGameShaders.WeaponShaders.WeaponEnvShader'
     TransientSoundVolume=0.600000
     SkillCost=2000
     StationDmgModifier=15
}
